package com.yc.Testjvm;

import java.lang.ref.WeakReference;

public class TestWeakReference {
	
	/**
	 * 弱引用：只要gc，就被回收
	 */
	public void m1() {
		WeakReference<S> a = new WeakReference<S>(new S("ss"));
		System.out.println(a.get());
		System.gc();
		System.out.println(a.get());
		
	}

	public static void main(String[] args) {
		TestWeakReference twr = new TestWeakReference();
		twr.m1();

	}

	class S {
		private String a;

		public S(String a) {
			super();
			this.a = a;
		}
	}
}
